﻿/**
 * @file brief_logic.h
 * @date 2021/04/16 15:24
 *
 * @author harrybao (harrybao@123u.com)
 *
 * @brief 公会简略信息逻辑
 *
 * @version v1.0.0
 *
 * @copyright Copyright © 2021 All Rights Reserved 上海欢乐互娱网络科技有限公司
 *
 * @par history:
 * <table>
 * <tr><th>Date                     <th>Version     <th>Author <th>Description
 * <tr><td>2021/04/16 15:24         <td>1.0.0       <td>harrybao
 * <td>创建初始版本
 * </table>
 */

#ifndef GUILD_BRIEF_LOGIC_H
#define GUILD_BRIEF_LOGIC_H

#pragma once

#include <functional>
#include <vector>

#include "error/error_code.h"
#include "guild/guild.h"

struct GuildModuleBrief;

namespace guild_service {

/**
 * @brief 公会简略信息逻辑类
 *
 */
class GuildBriefLogic {
 public:
  /**
   * @brief 获取公会简略信息模块
   *
   * @param guild_id
   * @param brief
   * @return true
   * @return false
   */
  static bool GetGuildModuleBrief(const guild_id_type guild_id, GuildModuleBrief &brief);

  /**
   * @brief Get the Guild Brief object
   *
   * @param role_uuid
   * @param brief
   * @return true
   * @return false
   */
  static bool GetGuildModuleBriefByRole(const role_uuid_type role_uuid,
                                        GuildModuleBrief &brief,
                                        error_code &ec);
  /**
   * @brief 获取公会id
   *
   * @param role_uuid 角色唯一id
   * @param guild_id 公会id
   * @return true 获取成功
   * @return false 获取失败
   */
  static bool GetGuildIdByRole(const role_uuid_type role_uuid,
                               guild_id_type &guild_id);

  /**
   * @brief Get the Guild Brief List object
   *
   * @param role_uuid
   * @param res
   * @param ec
   * @return true
   * @return false
   */
  static bool GetGuildBriefList(const role_uuid_type role_uuid,
                                std::size_t count,
                                std::vector<GuildModuleBrief> &brief_list,
                                error_code &ec);

  /**
   * @brief 获取公会简略信息
   *
   * 筛选符合指定条件的公会
   *
   * @param role_uuid
   * @param name
   * @param brief
   * @param ec
   * @return true
   * @return false
   */
  static bool SearchGuild(const role_uuid_type role_uuid,
                          const std::string &name, GuildModuleBrief &brief,
                          error_code &ec);

 private:
  using ForeachGuildBriefCallbackType = std::function<bool(
      const GuildModuleBrief &)>;  ///< 遍历公会简略信息回调函数类型

  /**
   * @brief
   *
   * @param callback
   */
  static void ForeachGuildBrief(const ForeachGuildBriefCallbackType &callback);
};

}  // namespace guild_service

#endif  // GUILD_BRIEF_LOGIC_H